package com.model.xmlElement.output;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * *********************************************
 * @author Administrator
 * @FileName OutputFileLocal.java
 * @DescriptionXML配置之本地文件配置
 **********************************************
 */
@XmlAccessorType(XmlAccessType.FIELD)
public class OutputFileLocal implements Serializable{
	public static final Logger LOG = LoggerFactory.getLogger(OutputFileLocal.class);
	private static final long serialVersionUID = 1L;
	
	@XmlElement(name = "output_local_file_dir")
	private String outputLocalFileDir;						//本地->输出文件夹
	
	@XmlElement(name = "output_local_file_name")
	private String outputLocalFileName;						//本地->输出文件名字
	
	@XmlElement(name = "output_local_file_ext")
	private String outputLocalFileExt;						//本地->输出文件后缀
	
	@XmlElement(name = "output_local_file_encoding")
	private String outputLocalFileEncoding;					//本地->输出文件编码
	
	@XmlElement(name = "output_local_file_maxkbs")
	private String outputLocalFileMaxKbs;					//本地->输出单个文件最大多少KB
	
	public void setOutputLocalFileDir(String outputLocalFileDir) {
		this.outputLocalFileDir = outputLocalFileDir;
	}

	public void setOutputLocalFileName(String outputLocalFileName) {
		this.outputLocalFileName = outputLocalFileName;
	}

	public void setOutputLocalFileExt(String outputLocalFileExt) {
		this.outputLocalFileExt = outputLocalFileExt;
	}

	public void setOutputLocalFileEncoding(String outputLocalFileEncoding) {
		this.outputLocalFileEncoding = outputLocalFileEncoding;
	}

	public String getOutputLocalFileMaxKbs() {
		return outputLocalFileMaxKbs;
	}

	public void setOutputLocalFileMaxKbs(String outputLocalFileMaxKbs) {
		this.outputLocalFileMaxKbs = outputLocalFileMaxKbs;
	}

	public OutputFileLocal() {
		super();
	}

	/**
	 * 文件名加后缀"_1"
	 * @return
	 */
	public String getOutputLocalFileName() {
		return outputLocalFileName + "_1";
	}
	/**
	 * 完整本地路径
	 * @return
	 */
	public String getOutputLocalFileDir(String taskId,String taskTime,String taskSource) {
		StringBuilder stringBuilder = new StringBuilder(100);
		if(outputLocalFileDir.charAt(outputLocalFileDir.length() - 1) != '/'){
			stringBuilder.append(outputLocalFileDir).append("/").append(taskId).append("_").append(taskTime).append("_").append(taskSource).append("/");
		}else{
			stringBuilder.append(outputLocalFileDir).append(taskId).append("_").append(taskTime).append("_").append(taskSource).append("/");
		}
		return stringBuilder.toString();
	}
	/**
	 * 完整本地种子路径
	 * @return
	 */
	public String getOutputSeedLocalFileDir(String taskId,String taskTime,String taskSource) {
		StringBuilder stringBuilder = new StringBuilder(100);
		if(outputLocalFileDir.charAt(outputLocalFileDir.length() - 1) != '/'){
			stringBuilder.append(outputLocalFileDir).append("/").append(taskId).append("_").append(taskTime).append("_").append(taskSource).append("_").append("seed").append("/");
		}else{
			stringBuilder.append(outputLocalFileDir).append(taskId).append("_").append(taskTime).append("_").append(taskSource).append("_").append("seed").append("/");
		}
		return stringBuilder.toString();
	}
	/**
	 * 完整文件名
	 * @param uuid
	 * @param user
	 * @param dateString
	 * @return
	 */
	public String getOutputLocalFilePath(String taskId,String user,String taskTime,String taskSource){
		StringBuilder stringBuilder = new StringBuilder(200);
		stringBuilder.append(getOutputLocalFileDir(taskId,taskTime,taskSource)).append("task_").append(taskId).append("_").append(user).append("_").append(taskTime).append("_").append(getOutputLocalFileName()).append(".").append(outputLocalFileExt);
		return stringBuilder.toString();
	}
	/**
	 * 完整种子文件名
	 * @param uuid
	 * @param user
	 * @param dateString
	 * @return
	 */
	public String getOutputLocalSeedsFilePath(String taskId,String user,String taskTime,String taskSource){
		StringBuilder stringBuilder = new StringBuilder(200);
		stringBuilder.append(getOutputSeedLocalFileDir(taskId,taskTime,taskSource)).append("task_").append(taskId).append("_").append(user).append("_").append(taskTime).append("_").append(getOutputLocalFileName()).append("_").append("seed").append(".").append(outputLocalFileExt);
		return stringBuilder.toString();
	}
	/**
	 * 文件默认后缀
	 * @return
	 */
	public String getOutputLocalFileExt() {
		return (outputLocalFileExt == null || outputLocalFileExt.equals("")) ? "txt" : outputLocalFileExt;
	}
	/**
	 * 文件默认编码
	 * @return
	 */
	public String getOutputLocalFileEncoding() {
		return (outputLocalFileEncoding == null || outputLocalFileEncoding.equals("")) ? "UTF-8" : outputLocalFileEncoding;
	}

}
